<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div id="app">
        <!-- 数组类型的修改需要使用Vue中包装过的改变数组的方法,不改变数组的方法需要覆盖原data中的数组 -->
        <p v-for="item in names">{{item}}</p>
        <button @click="add">加一</button>
        <button @click="delete1">减一</button>
        <!-- <button @click="deleteAttr">名字</button> -->
    </div>
    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    names: ["wucy", "zhangsan", "lily"]
                }
            },
            methods: {
                add(){
                    this.names.push('文水洪')
                },
                delete1(){
                  this.names=this.names.filter(item=>item!=='文水洪')
                }
            }
        })
    </script>
</body>

</html>